package com.hddf.project.auth.interceptor;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.kommii.log.LogWriter;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

	public class LoginInterceptor extends AbstractInterceptor {  
		  
		private static final long serialVersionUID = 565445990123435L;

		@Override  
	    public  String intercept(ActionInvocation invocation) throws Exception { 
			String res = invocation.invoke();
	        // 取得请求相关的ActionContext实例  
	        HttpServletRequest request = null;
	        request = (HttpServletRequest) invocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
	        System.out.println("+++++ login Interceptor +++++++");
			String logname = (String)request.getAttribute("logname");
			System.out.println(logname);
			String logs = (String)request.getAttribute("logs");
			System.out.println(logs);
			if(null!=logname){
				LogWriter.writeLog(logname,null,logs);
			}
			return res;
					
		}
	}


